package Control;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public final class DatabaseConn {
    
    private  Connection conn;
    private  Statement stmt;

    public DatabaseConn(){
   
         try {
            Class.forName("com.mysql.jdbc.Driver");
            Connection conn;

            String db = "quizkampen";
            String url = "jdbc:mysql://localhost:3306/" + db;
            String user = "root";
            String pw = "karen";

            conn = DriverManager.getConnection(url, user, pw);
            stmt = conn.createStatement();

        } catch (ClassNotFoundException ex) {
            System.out.println(ex);
        } catch (SQLException ex) {
            System.out.println(ex);
        }

    } 
    
    public ResultSet getResultset(String sql) throws SQLException{
        ResultSet rs = stmt.executeQuery(sql);
        return rs;
    }

}
